package com.aboo.util;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/**
 * @author Yata Aboo
 * @Date 2012-9-19
 * @Desc Ajax工具包
 */
public class AjaxUtil {
	
	private static final Logger logger = Logger.getLogger(AjaxUtil.class);

	/**
	 * 向页面输出指定内容
	 * @param response response对象
	 * @param str 输出内容
	 */
	public static void doAjax(HttpServletResponse response, String str) {
		PrintWriter out = null;
		try {
			response.setCharacterEncoding("UTF-8");
			response.setHeader("Cache-Control", "no-cache");
			out = response.getWriter();
			out.println(str);
		} catch (Exception e) {
			logger.error("AJAX返回出错！", e);
		} finally {
			out.close();
		}
	}
	
}
